(function(){"use strict";BX.namespace("BX.Filter");BX.Filter.Api=function(e){this.parent=e};BX.Filter.Api.prototype={setFields:function(e){var t,i;if(BX.type.isPlainObject(e)){this.parent.getPopup();t=this.parent.getPreset();t.deactivateAllPresets();i={preset_id:"tmp_filter",fields:e};this.parent.updateParams(i);t.applyPreset("tmp_filter")}},setFilter:function(e){if(typeof e==="object"){this.parent.updateParams(e);this.parent.getPreset().deactivateAllPresets();this.parent.getPreset().activatePreset(e.preset_id);this.parent.getPreset().applyPreset(e.preset_id);if(!e.checkFields||!this.parent.getPreset().isPresetValuesModified(e.preset_id)){this.parent.applyFilter(false,e.preset_id)}else{var t={};if(BX.type.isPlainObject(e.fields)){t=Object.assign({},e.fields)}if(BX.type.isPlainObject(e.additional)){t=Object.assign({},e.additional)}this.parent.getPreset().deactivateAllPresets();this.setFields(t);this.apply()}}},extendFilter:function(e){if(!!e&&typeof e==="object"){Object.keys(e).forEach(function(t){if(BX.type.isNumber(e[t])){e[t]=""+e[t]}});var t=this.parent.getPreset().getCurrentPresetId();if(t==="tmp_filter"||t==="default_filter"){var i=Object.assign({},this.parent.getFilterFieldsValues(),e);this.setFields(i);this.apply();return}var s=this.parent.getPreset().getAdditionalValues(t);if(BX.type.isPlainObject(s)&&Object.keys(s).length){e=Object.assign({},s,e)}this.setFilter({preset_id:t,additional:e,checkFields:true})}},apply:function(){if(!this.parent.isEditEnabled()){if(!this.parent.isEditEnabled()){this.parent.applyFilter()}this.parent.closePopup();if(this.parent.isAddPresetEnabled()){this.parent.disableAddPreset()}}}}})();